<?php

class Admin_bank_model extends CI_Model {

    function index() {
        $q = $this->db->get('admin_bank');
        return $q;
    }

    function show($id) {
        $this->db->where('id', $id);
        $q = $this->db->get('admin_bank');
        return $q;
    }

    function edit($id) {
        $this->db->where('id', $id);
        $q = $this->db->get('admin_bank');
        return $q;
    }

    function create($bank_name, $an, $no_rek) {
        $data = array(
            'bank_name' => $bank_name,
            'an' => $an,
            'no_rekening' => $no_rek,
        );
        $this->db->insert('admin_bank', $data);
        redirect('admin_bank/index');
    }

    function update($id, $bank_name, $an, $no_rekening) {
        $data = array(
            'bank_name' => $bank_name,
            'an' => $an,
            'no_rekening' => $no_rekening,
        );
        $this->db->where('id', $id);
        $this->db->update('admin_bank', $data);
        redirect('admin_bank/index');
    }

    function delete($id) {
        $this->db->where('id', $id);
        $this->db->delete('admin_bank');
        redirect('admin_bank/index');
    }
    
    function get_bank($bank){
        $this->db->where('bank_name', $bank);
        $q = $this->db->get('admin_bank');
        
        foreach($q->result() as $row):
            return $row->bank_name.$row->no_rekening;
        endforeach;
        
    }

}

?>
